/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hxg.portmgr.core.arp;

/**
 *
 * @author hxg
 */
public class VlanMacPort {

    int vlan;
    int[] mac;
    String portIfindex;
    //注意OID的组合为[1.3.6.1.2.1.17.7.1.2.2.1.2.vlan.mac_address(转10进制)]=[端口IF]
    //Name/OID: dot1dBasePortIfIndex.105; Value (Integer): 134217737  portID 与 IntfID 对应关系 
    //.1.3.6.1.2.1.17.1.4.1.2.105
    final public static String dot1qTpFdbPort = "1.3.6.1.2.1.17.7.1.2.2.1.2";
    final public static String dot1qTpFdbAddress = "1.3.6.1.2.1.17.7.1.2.2.1.1";
    //final public static String dot1dBasePortIfIndex = "1.3.6.1.2.1.17.1.4.1.2";

    private VlanMacPort(int[] mac, int vlan, String portIfindex) {
        this.mac = mac;
        this.vlan = vlan;
        this.portIfindex = portIfindex;
    }
    
    public static VlanMacPort createVlanMacPort(int[] mac, int vlan, String portIfindex){
        return new VlanMacPort(mac, vlan, portIfindex);
    }

    public int[] getMac() {
        return mac;
    }
    
    public String getMacString(){
        StringBuilder sb=new StringBuilder();
        for(int i=0;i<mac.length;i++){
            sb.append('-');
            String hex=Integer.toHexString(mac[i]);
            if(hex.length()==1){
                sb.append('0');
            }
            sb.append(hex.toUpperCase());
        }
        return sb.substring(1);
    }

    public String getPortIfindex() {
        return portIfindex;
    }

    public int getVlan() {
        return vlan;
    }

    @Override
    public String toString() {
        return "VlanMacPort{" + "vlan=" + vlan + ", mac=" + getMacString() + ", portIfindex=" + portIfindex + '}';
    }
    
   
}
